home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / windows / ccdial10.zip / CCDIALER.WAS next >
Text File  |  1992-10-22  |  17KB  |  301 lines

  1. ;CCDIALER.WAS   - 1.00 Credit Card Dialer
  2.  
  3. ;****************************************************************************
  4. ;*                                                                          *
  5. ;* CCDIALER.WAS                                                             *
  6. ;* Copyright (C) 1992 Datastorm Technologies, Inc                           *
  7. ;*                                                                          *
  8. ;* Purpose: To Automate the dialing of long distance credit card            *
  9. ;*          numbers.  This script will make it easier to use the            *
  10. ;*          dialing directory without the need to set up long distance      *
  11. ;*          codes.                                                          *
  12. ;*                                                                          *
  13. ;* Program Flow: Enter Credit Card Information                              *
  14. ;*               Create the Dialing Directory List                          *
  15. ;*               Have User Choose the entry to dial                         *
  16. ;*               Transmit the Long Distance Service Number                  *
  17. ;*               Wait the specified Service Wait                            *
  18. ;*               Transmit the Telephone Number                              *
  19. ;*               Wait the specifiec Pre-Card Wait                           *
  20. ;*               Transmit the Credit Card Number                            *
  21. ;*               Wait for a Connection                                      *
  22. ;*               Execute the Diling Directory Script - If any               *
  23. ;*                                                                          *
  24. ;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.   *
  25. ;* DATASTORM makes no warranty of any kind, express or implied, including   *
  26. ;* without limitation, any warranties of merchantability and/or fitness     *
  27. ;* for a particular purpose.  Use of this program is at your own risk.      *
  28. ;*                                                                          *
  29. ;* Author: Kevin Bailey                                                     *
  30. ;****************************************************************************
  31.                                                                     
  32. ;****************************************************************************
  33. ;* MACRO DEFINITIONS                                                        *
  34. ;****************************************************************************
  35. #define ATDT "ATDT"                      ;Shorthand for commonly used string
  36. #define GLUE ";^M"                       ;Shorthand.........
  37. #define ENTER "^M"                       ;Shorthand.........
  38.  
  39. ;****************************************************************************
  40. ;* GLOBAL VARIABLES                                                         *
  41. ;****************************************************************************
  42. string modinit                           ;Modem Init string
  43. string initfile="CCDIALER.INI"           ;Init file name
  44. string dirfile="ccdialer.dir"            ;Temporary Dialing Directory file
  45. string ServiceNum                        ;Service Number
  46. string CardNum                           ;Credit Card Number
  47. string TempWait1="10"                    ;Pre-set wait after dialing service
  48. string TempWait2="5"                     ;Pre-set wait before dialing Card
  49. string dchoice                           ;Dialing directory choice
  50. integer ServiceWait                      ;Wait after dialing service number
  51. integer PreCardWait                      ;Wait before dialing credit card
  52. integer stat                             ;Status flag
  53. integer dialndx                          ;Index number of dialing entry
  54.  
  55. ;****************************************************************************
  56. ;*                                                                          *
  57. ;* MAIN                                                                     *
  58. ;* The main procedure calls all set up procedures and does the dialing of   *
  59. ;* the service, telephone and credit card numbers.                          *
  60. ;*                                                                          *
  61. ;* Calls: setfile, getddir, choose, nomodem, cleanup                        *
  62. ;* Modifies Globals: dialndx                                                *
  63. ;****************************************************************************
  64. proc main
  65.  
  66.    when userexit call cleanup            ;Trap user exits events
  67.  
  68.    setfile()                             ;Initialize variables
  69.    getddir()                             ;Initialize directory list
  70.    choose()                              ;Choose entry to dial
  71.    
  72.    if stat == 1                          ;If CANCEL is chosen,
  73.       cleanup()                          ;exit CCDIALER.WAS
  74.    endif
  75.  
  76.    dialfind dchoice dialndx              ;Find the dialing entry
  77.    set dialdir access dialndx            ;Set access
  78.  
  79.    fetch modem init modinit              ;Save the init string
  80.    transmit "^M^M^M"                     ;Clear the modem
  81.    pause 1                               ;Allow the modem to settle
  82.    clear                                 ;Clear the screen
  83.    transmit "ATX1M1^M"                   ;Blind the modem, reduce CD wait.
  84.    pause 1
  85.    transmit "ATS7=127^M"                 ;Boost wait time for carrier.
  86.    pause 1
  87.    statmsg "Dialing the Service Number: %s" ServiceNum
  88.    transmit ATDT                         ;
  89.    transmit ServiceNum                   ;Dial the ServiceNum.
  90.    transmit Glue                         ;
  91.    waitfor "OK" 5                        ;Wait for an affirmative response.
  92.    if failure                            ;If the modem did not respond,
  93.       nomodem()                          ;then bail-out.
  94.    endif                                
  95.    pause ServiceWait                     ;Wait for the second tone.
  96.  
  97.    statmsg "Dialing Telephone Number: %s" $D_NUMBER
  98.    transmit ATDT                         ;
  99.    transmit $D_NUMBER                    ;Dial the phone number
  100.    transmit Glue                         ;from the dialing dir.
  101.    waitfor "OK" 5                        ;Wait for an affirmative response.
  102.    if failure                            ;If the modem did not respond,
  103.       nomodem()                          ;then bail-out.
  104.    endif                                
  105.    pause PreCardWait                     ;Wait for the third tone
  106.  
  107.    statmsg "Dialing credit card information."
  108.    transmit ATDT                         ;
  109.    transmit CardNum                      ;Dial the credit card number.
  110.    transmit ENTER                        ;
  111.    clear                                 ;Clear the screen.
  112.    statmsg "Waiting for carrier."        ;Keep the user informed.
  113.  
  114.    waitfor "CONNECT" 40                  ;Wait for the CONNECT
  115.    if success                            ;message from modem.
  116.       if $CARRIER                        ;Make sure CARRIER is high
  117.          execute $D_SCRIPT               ;Execute Directory Script
  118.       endif
  119.    endif
  120.    cleanup()                             ;Finished.
  121. endproc                                  ;
  122.  
  123. ;****************************************************************************
  124. ;*                                                                          *
  125. ;* NOMODEM                                                                  *
  126. ;* This modem reports an error back to the user that the modem has not      *
  127. ;* responded to the commands sent.                                          *
  128. ;*                                                                          *
  129. ;* Calls: N/A                                                               *
  130. ;* Called By: MAIN                                                          *
  131. ;* Modifies Globals: N/A                                                    *
  132. ;****************************************************************************
  133. proc nomodem
  134.    usermsg "Modem did not respond.  Try increasing transmit pacing."
  135.    transmit "^M^M"                       ;Clear the modem and attempt to
  136.    transmit modinit                      ;reset modem to default settings.
  137.    cleanup()                             ;Back to the terminal
  138. endproc
  139.  
  140. ;****************************************************************************
  141. ;*                                                                          *
  142. ;* SETFILE                                                                  *
  143. ;* This procedure maintains the CCDIALER.INI file which contains the        *
  144. ;* service and credit card numbers to use while dialing.                    *
  145. ;*                                                                          *
  146. ;* Calls: NUMINIT                                                           *
  147. ;* Called By: MAIN                                                          *
  148. ;* Modifies Globals: ServiceNum, CardNum, TempWait1, TempWait2,             *
  149. ;*                   ServiceWait, PreCardWait                               *
  150. ;****************************************************************************
  151. proc setfile
  152.  
  153.    fopen 0 initfile READWRITE TEXT       ;Open the init file
  154.    if success                            ;File exists
  155.       fgets 0 ServiceNum                 ;Read in the service number
  156.       fgets 0 CardNum                    ;Read in the credit card
  157.       fgets 0 TempWait1                  ;Read in the service wait
  158.       fgets 0 TempWait2                  ;Read in the credit card wait
  159.       fclose 0                           ;Close the init file
  160.       atoi TempWait1 ServiceWait         ;Convert to an integer
  161.       atoi TempWait2 PreCardWait         ;Convert to an integer
  162.    endif
  163.    statmsg "Parameter Setup"
  164.    numinit()                             ;Display the setup dialog
  165. endproc
  166.  
  167. ;****************************************************************************
  168. ;*                                                                          *
  169. ;* NUMINIT                                                                  *
  170. ;* Displays the dialog box with the current settings and allows the user    *
  171. ;* to modify them before continuing.                                        *
  172. ;*                                                                          *
  173. ;* Calls: N/A                                                               *
  174. ;* Called By: SETFILE                                                       *
  175. ;* Modifies Globals: ServiceNum, CardNum, TempWait1, TempWait2,             *
  176. ;*                   ServiceWait, PreCardWait                               *
  177. ;****************************************************************************
  178. proc numinit
  179.  
  180.    dialogbox 88 57 196 146 3 "Credit Card Dialer Setup"
  181.       text  6 6 184 8 left "Service Number to Dial:"
  182.       editbox 5 14 182 13 ServiceNum 40
  183.       text  6 36 174 8 left "Credit Card Number:"
  184.       editbox 5 44 181 13 CardNum 40
  185.       text  6 70 112 8 left "Pause AFTER Service Number:"
  186.       editbox 121 67 32 12 TempWait1 3
  187.       text  154 70 34 8 left "seconds"
  188.       text  6 86 110 8 left "Pause BEFORE Card Number:"
  189.       editbox 121 84 32 12 TempWait2 3
  190.       text  154 86 32 8 left "seconds"
  191.       pushbutton 41 115 40 14 "Cont" normal
  192.       pushbutton 110 115 40 14 "Quit" cancel
  193.    enddialog
  194.  
  195.    updatedlg -1                          ;Display the dialog
  196.    while 1                               ;Loop until Cont or Quit
  197.       switch $dialog
  198.          case 230                        ;ServiceNum Edit Box
  199.             updatedlg 8
  200.          endcase
  201.          case 231                        ;CardNum Edit Box
  202.             updatedlg 9
  203.          endcase
  204.          case 232                        ;ServiceWait Edit Box
  205.             updatedlg 10
  206.          endcase
  207.          case 233                        ;PreCardWait Edit Box
  208.             updatedlg 11
  209.          endcase
  210.          case 1                          ;Quit button selected
  211.             cleanup()                    ;Exit CCDIALER.WAS
  212.          endcase
  213.          case 10                         ;Cont button selected
  214.             exitwhile                    ;Exit the while loop
  215.          endcase
  216.       endswitch
  217.    endwhile
  218.    
  219.    atoi TempWait1 ServiceWait            ;Convert to integer
  220.    atoi TempWait2 PreCardWait            ;Convert to integer
  221.    fopen 0 initfile CREATE TEXT          ;Open the init file
  222.    fputs 0 ServiceNum                    ;Write ServiceNum
  223.    fputs 0 CardNum                       ;Write CardNum
  224.    fputs 0 TempWait1                     ;Write ServiceWait
  225.    fputs 0 TempWait2                     ;Write PreCardWait
  226.    fclose 0                              ;Close init file
  227.  
  228. endproc
  229.  
  230. ;****************************************************************************
  231. ;*                                                                          *
  232. ;* GETDDIR                                                                  *
  233. ;* This procedure saves the dialing directory entry names to a temporary    *
  234. ;* file on disk to be displayed to the user during the CHOOSE procedure.    *
  235. ;*                                                                          *
  236. ;* Calls: N/A                                                               *
  237. ;* Called By: MAIN                                                          *
  238. ;* Modifies Globals: N/A                                                    *
  239. ;****************************************************************************
  240. proc getddir
  241. ;****************************************************************************
  242. ;*   LOCAL VARIABLES                                                        *
  243. ;****************************************************************************
  244.    integer   ent=1                       ;Count variable
  245.  
  246.    fopen 1 dirfile CREATE TEXT           ;Open the temporary file
  247.  
  248.    while ent <= $DIALCOUNT               ;Loop until all entries processed
  249.       set dialdir access ent             ;Set current directory entry
  250.       fputs 1 $D_NAME                    ;Write the entry name
  251.       ent = ent + 1                      ;Increment counter
  252.    endwhile
  253.    fclose 1                              ;Close the file
  254. endproc
  255.  
  256. ;****************************************************************************
  257. ;*                                                                          *
  258. ;* CHOOSE                                                                   *
  259. ;* The procedure choose provides the user with a list of entries which      *
  260. ;* may be dialed, from which he/she may select one or more.                 *
  261. ;*                                                                          *
  262. ;* Calls: N/A                                                               *
  263. ;* Called by: MAIN                                                          *
  264. ;* Modifies globals: stat                                                   *
  265. ;*                                                                          *
  266. ;****************************************************************************
  267. proc choose
  268.    dialogbox 25 10 193 98 3 "Credit Card Dialing Selection"
  269.       text  1 3 77 8 center "Name"
  270.       flistbox 5 17 181 61 dirfile single dchoice
  271.       pushbutton 53 75 40 14 "OK" normal default
  272.       pushbutton 113 75 40 14 "Cancel" cancel
  273.    enddialog
  274.  
  275.    stat=$DIALOG                          ;Save the DIALOG status
  276.    while stat != 10 && stat != 1         ;Loop until OK or CANCEL
  277.       stat=$DIALOG                       ;Save the DIALOG status
  278.    endwhile
  279. endproc
  280.  
  281. ;****************************************************************************
  282. ;*                                                                          *
  283. ;* CLEANUP                                                                  *
  284. ;* This procedure closes and deletes all temporary files used.              *
  285. ;*                                                                          *
  286. ;* Calls: N/A                                                               *
  287. ;* Called By: MAIN, NUMINIT, NOMODEM                                        *
  288. ;* Modifies Globals: N/A                                                    *
  289. ;****************************************************************************
  290. proc cleanup
  291.  
  292.    statmsg "Exiting CCDIALER."           ;Notify User
  293.  
  294.    isfile dirfile                        ;Check for file
  295.    if success
  296.       delfile dirfile                    ;Delete file
  297.    endif
  298.  
  299.    exit                                  ;Exit CCDIALER.WAS
  300. endproc
  301.